<?python
	from whatwhat.model import STATUS_BEHIND_SCHEDULE
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
    py:extends="'../master.kid'">

<head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
    <title>WhatWhat Status Dashboard</title>
	<script src="/static/javascript/master.js" type="text/javascript"></script>
	<link href="/static/css/master.css" media="screen" rel="Stylesheet" type="text/css" /> 
	<link href="/static/css/dashboard.css" media="screen" rel="Stylesheet" type="text/css" /> 
</head>

<body>
    <h2>Project Dashboard</h2>

	<h3>Active Projects</h3>
	
	<div class="project" onclick="document.location.href='${tg.url('/project/%s' % project.id)}'" py:for="project in projects">
		<div class="top">
			<h3 py:content="project.name" />
			<span py:if="project.status != STATUS_BEHIND_SCHEDULE" class="status good" py:content="status_codes.get(project.status)" />
			<span py:if="project.status == STATUS_BEHIND_SCHEDULE" class="status bad" py:content="status_codes.get(project.status)" />
		</div>
		<div class="bottom">
			<span class="contact">
				<span class="label">Contact:</span>
				<a href="mailto:$project.contact.emailAddress" py:content="project.contact.displayName" />
			</span>
			<span class="info">
				<span py:replace="len(project._total_risks())">some</span> 
				risks, <span py:replace="len(project._total_issues())">some</span> issues,
				<span py:replace="len(project._total_notes())">some</span> notes,
				<span py:replace="len(project._total_files())">some</span> files,
				<span py:replace="len(project._total_questions())">some</span> questions,
				<span py:replace="len(project._total_answers())">some</span> answers 
				<br/>
				<span py:if="len(project.delayed_subprojects) > 0">
					and <span py:replace="len(project.delayed_subprojects)" /> delayed subprojects 
					(<a py:for="i, sub_project in enumerate(project.delayed_subprojects)" href="/project/$sub_project.id" title="$sub_project.name">${i+1}&#160;</a>)
				</span>
				
				
			</span>
		</div>
	</div>
	
	<br/>
	
	<a href="#" onclick="toggle('new_project'); clr('ta_new_project');fcs('tf_desc'); return false;">new project</a>
	<div id="new_project" style="display: none;">
		<form id="form_new_project" action="new_project" method="post">
			<table>
				<tr><td width="120"><b>Project Name:</b></td><td><input id="tf_desc" type="text" name="name" size="50" /></td></tr>
				<tr>
					<td><b>Contact:</b></td>
					<td>
						<select name="contact_id">
							<option py:for="person in people" value="$person.id">
								${person.displayName}
							</option>
						</select>
					</td>
				</tr>
				<tr>
					<td><b>Create Sub-projects</b></td>
					<td><input type="checkbox" name="subprojects" /></td>
				</tr>
				<tr>
					<td colspan="2"><b>Project Description</b></td>
				</tr>
				<tr>
					<td colspan="2">
						<textarea id="ta_new_project" rows="4" name="description" cols="72"></textarea>
					</td>
				</tr>
			</table>
			<a href="#" onclick="submit('form_new_project'); return false;">add</a>
			<a href="#" onclick="toggle('new_project'); return false;">cancel</a>
		</form>
	</div>
	
	<br/><br/>
	
	<h3>Archived Projects</h3>
	
	<a href="#" id="show_archived" onclick="toggle('archived_projects');toggle('show_archived');toggle('hide_archived'); return false;">show archived projects</a>
	<a href="#" style="display: none" id="hide_archived" onclick="toggle('archived_projects');toggle('show_archived');toggle('hide_archived'); return false;">hide archived projects</a>
	
	<div style="display: none" id="archived_projects">
		<div class="project archived" onclick="document.location.href='${tg.url('/project/%s' % project.id)}'" py:for="project in archived_projects">
			<div class="top">
				<h3 py:content="project.name" />
				<span class="status archived">Archived</span>
			</div>
		</div>
	</div>
</body>
</html>
